		
	** Uganda 
	** Clean wave 1

	
	** Urban status
	
		use "$dir/rawdata/LSMS Uganda/2009/2009_GSEC1.dta", clear
		gen w1_urban=urban==1
		
		keep HHID w1*
		ren HHID hhid
		
		tempfile urban
		save `urban', replace
		
	** Roster
		use "$dir/rawdata/LSMS Uganda/2009/2009_GSEC2.dta", clear
		
		gen w1_female=h2q3==2 if !missing(h2q3)
		gen w1_age=h2q8
		gen w1_married=(h2q10==1 | h2q10==2) if !missing(h2q10)
		
		gen w1_inhh=h2q7<=4
		
		bys HHID: egen w1_hh_size=total(w1_inhh)
		
		ren HHID hhid
		ren PID indiv
		
		keep hhid indiv w1_*
		tempfile roster
		save `roster', replace
		
	** Illness or injury
	
		use "$dir/rawdata/LSMS Uganda/2009/2009_GSEC5.dta", clear
	
		gen w1_illinj=H5q4==1 if !missing(H5q4)
		gen w1_illinjstopactivities=H5q6>0 if !missing(H5q6)
		replace w1_illinjstopactivities=0 if w1_illinj==0
		
		ren Hhid hhid
		ren Pid indiv 
		
		keep hhid indiv w1_*		
		tempfile illinj
		save `illinj', replace
		
	** Employment 
		
		use "$dir/rawdata/LSMS Uganda/2009/2009_GSEC8.dta", clear
		
		gen w1_work_outsideHH=H8q04==1 if !missing(H8q04)
		
		gen w1_work_bizHH=(H8q06==1 | H8q08==1) if (!missing(H8q06) | !missing(H8q08))
		
		gen w1_work_agHH=(H8q12==1) if !missing(H8q12)
		*egen w1_work_agHH_hrs=rowtotal(H8q65 H8q66), mi
		
		egen w1_worked_last7days=rowmax(w1_work_outsideHH w1_work_agHH w1_work_bizHH)
		egen w1_work_hrs=rowtotal(H8q36a H8q36b H8q36c H8q36d H8q36e H8q36f H8q36g H8q43), mi // inludes working on a household business, agriculture, etc.
		
		ren Hhid hhid
		ren Pid indiv
		keep hhid indiv w1_*
		
		tempfile employment
		save `employment', replace
	
	** Disabilities

		use "$dir/rawdata/LSMS Uganda/2009/2009_GSEC7.dta", clear

		** Difficulty seeing
		tab1 H7q2a, nol
		tab1 H7q2a
		gen w1_diff_seei=1 if inlist(H7q2a, 2, 3, 4) 
		replace w1_diff_seei=0 if inlist(H7q2a, 1)
		replace w1_diff_seei=. if inlist(H7q2a, .)
		tab1 w1_diff_seei

		** Difficulty hearing
		tab1 H7q3a, nol
		tab1 H7q3a
		gen w1_diff_hear=1 if inlist(H7q3a, 2, 3, 4) 
		replace w1_diff_hear=0 if inlist(H7q3a, 1)
		replace w1_diff_hear=. if inlist(H7q3a, .)
		tab1 w1_diff_hear

		** Difficulty walking or climbing stairs	
		tab1 H7q4a, nol
		tab1 H7q4a
		gen w1_diff_walk_clim=1 if inlist(H7q4a, 2, 3, 4) 
		replace w1_diff_walk_clim=0 if inlist(H7q4a, 1)
		replace w1_diff_walk_clim=. if inlist(H7q4a, .)
		tab1 w1_diff_walk_clim

		** Difficulty remembering or concentrating
		tab1 H7q5a, nol
		tab1 H7q5a
		gen w1_diff_reme=1 if inlist(H7q5a, 2, 3, 4) 
		replace w1_diff_reme=0 if inlist(H7q5a,1)
		replace w1_diff_reme=. if inlist(H7q5a, .)
		tab1 w1_diff_reme

		** Difficulty with self-care
		tab1 H7q6a, nol
		tab1 H7q6a
		gen w1_diff_self_care=1 if inlist(H7q6a, 2, 3, 4)
		replace w1_diff_self_care=0 if inlist(H7q6a, 1)
		replace w1_diff_self_care=. if inlist(H7q6a, .)
		tab1 w1_diff_self_care

		** Difficulty communicating
		tab1 H7q7a, nol
		tab1 H7q7a
		gen w1_diff_comm=1 if inlist(H7q7a, 2, 3, 4) 
		replace w1_diff_comm=0 if inlist(H7q7a, 1)
		replace w1_diff_comm=. if inlist(H7q7a, .)
		tab1 w1_diff_comm

		rename Hhid hhid
		rename Pid indiv 
		keep hhid indiv w1_*		
		tempfile disabilities
		save `disabilities', replace
		
	** Merge and save
	
		use `roster', clear
		merge 1:1 hhid indiv using `illinj', gen(merge_illinj)
		merge 1:1 hhid indiv using `employment', gen(merge_employment)
		merge 1:1 hhid indiv using `disabilities', gen(merge_disabilities)
		merge m:1 hhid using `urban', gen(merge_urban)
		
		save "$dir/data/uga_w1_individual.dta", replace
